<template>
  <view class="update-page">
    <update-modal
      ref="updateModal"
      :currentVersion="currentVersion"
      :latestVersion="latestVersion"
      :description="description"
      :forceUpdate="forceUpdate"
      @cancel="handleCancel"
    />
  </view>
</template>

<script>
import UpdateModal from '@/components/update-modal/update-modal.vue'

export default {
  components: {
    UpdateModal
  },
  data() {
    return {
      currentVersion: '',
      latestVersion: '',
      description: '',
      forceUpdate: false
    }
  },
  onLoad() {
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.on('updateInfo', (data) => {
      this.currentVersion = data.currentVersion
      this.latestVersion = data.latestVersion
      this.description = data.description
      this.forceUpdate = data.forceUpdate
      
      this.$nextTick(() => {
        this.$refs.updateModal.show()
      })
    })
  },
  methods: {
    handleCancel() {
      uni.navigateBack()
    }
  }
}
</script>

<style lang="scss" scoped>
.update-page {
  background: rgba(0,0,0,0.5);
  height: 100vh;
}
</style> 